package com.item.audrey_hepburn.base;/*/**

 _______  _______________   _________________________  __________ ____ ___  ________ 
 \      \ \_   _____/\   \ /   /\_   _____/\______   \ \______   \    |   \/  _____/ 
 /   |   \ |    __)_  \   Y   /  |    __)_  |       _/  |    |  _/    |   /   \  ___ 
/    |    \|        \  \     /   |        \ |    |   \  |    |   \    |  /\    \_\  \
\____|__  /_______  /   \___/   /_______  / |____|_  /  |______  /______/  \______  /
        \/        \/                    \/         \/          \/                 \/ 
 
 * @Auther: WD
 * @Date: 19-5-3 10:55
 * @Description: 
 */

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;

public class BaseController<T> {

    @Autowired
    protected T t;

    private JsonParser jsonParser = new JsonParser();

    //日志
    protected Logger logger = LoggerFactory.getLogger(getClass());


    protected ModelAndView mv = new ModelAndView();

    /**

     *@描述 ISO8859-1转为UTF-8

     *@参数  [s]

     *@返回值  java.lang.String

     *@创建人  wangdong

     *@创建时间  19-5-3/上午11:49

     *@修改人和其它信息

     */
    protected  String getISO8859ToUtf8(String s)throws Exception{
        if(s.isEmpty()){
            return null;
        }
        return new String(s.getBytes("ISO8859-1"),"UTF-8");
    }

    /**

     *@描述  字符串转jsonObject

     *@参数  [s]

     *@返回值  com.google.gson.JsonObject

     *@创建人  wangdong

     *@创建时间  19-5-3/下午12:14

     *@修改人和其它信息

     */
    public JsonObject getStringToJsonObject(String s){
        new Gson().toString();
        return jsonParser.parse(s).getAsJsonObject();
    }

}
